{include file="public/header"}
<div class="pub_wid notice_cont">
    <div class="notice_left bgb lf" id="sourceList">
        <h1>实时货源<span>当前位置：<a href="/index/index">主页</a>><a href="#">实时货源</a></span></h1>
        <ul class="widthauto notice_select">
            <li>行业：
                <select v-model="trade_name" @change="changeWhereGetList()">
                    <option value="">=全部=</option>
                    <option v-for="item in tradeList" :value="item.name">{{item.name}}</option>
                </select>
            </li>
            <li>服务：
                <select v-model="service_name" @change="changeWhereGetList()">
                    <option value="">=全部=</option>
                    <option v-for="item in serviceList" :value="item.name">{{item.name}}</option>
                </select>
            </li>
            <li id="distpicker" >省份：
                <select v-model="province" @change="changeWhereGetList()">
                    <option>请选择省</option>
                    <option>=全部=</option>
                </select>
            </li>
            <li>状态：
                <select v-model="end_time_status" @change="changeWhereGetList()">
                    <option value="">=全部=</option>
                    <option value="1">进行中</option>
                    <option value="2">已截止</option>
                </select>
            </li>
        </ul>
        <div class="widthauto notice_select">
            <input v-model="title_search"  placeholder="搜索招标公告"/>
            <button @click="changeWhereGetList()">搜索</button>
        </div>
        <div class="table_head widthauto"> <span class="big">标题</span><span class="sma">行业</span><span class="mid">报名开始时间</span><span class="mid">报名截止时间</span><span class="sma">状态</span> </div>
        <ul class="widthauto middl_ul">
            <li v-for="item in list">
                <a :href="'/index/source/detail/id/'+item.id">
                    <span class="big">{{item.province}}<i>|</i>{{item.title}}</span>
                    <span class="sma">{{item.trade_name}}</span>
                    <span class="mid">{{item.create_time}}</span>
                    <span class="mid">{{item.end_time}}</span>
                    <span v-if="item.end_time_status==1" class="sma ing">进行中</span>
                    <span v-if="item.end_time_status==2" class="sma end">已截止</span>
                </a>
            </li>
<!--            <li><a href="#"> <span class="big">山东<i>|</i>2021年度物流运输服务项目招标公告</span> <span class="sma">医药</span><span class="mid">2021-01-21</span><span class="mid">2021-01-21</span><span class="sma ing">进行中</span> </a></li>-->
<!--            <li><a href="#"> <span class="big">山东<i>|</i>2021年度物流运输服务项目招标公告</span> <span class="sma">医药</span><span class="mid">2021-01-21</span><span class="mid">2021-01-21</span><span class="sma ing">进行中</span> </a></li>-->
<!--            <li><a href="#"> <span class="big">山东<i>|</i>2021年度物流运输服务项目招标公告</span> <span class="sma">医药</span><span class="mid">2021-01-21</span><span class="mid">2021-01-21</span><span class="sma ing">进行中</span> </a></li>-->
<!--            <li><a href="#"> <span class="big">山东<i>|</i>2021年度物流运输服务项目招标公告</span> <span class="sma">零售连锁</span><span class="mid">2021-01-21</span><span class="mid">2021-01-21</span><span class="sma ing">进行中</span> </a></li>-->
<!--            <li><a href="#"> <span class="big">山东<i>|</i>2021年度物流运输服务项目招标公告</span> <span class="sma">医药</span><span class="mid">2021-01-21</span><span class="mid">2021-01-21</span><span class="sma ing">进行中</span> </a></li>-->
<!--            <li><a href="#"> <span class="big">山东<i>|</i>2021年度物流运输服务项目招标公告</span> <span class="sma">医药</span><span class="mid">2021-01-21</span><span class="mid">2021-01-21</span><span class="sma end">已截止</span> </a></li>-->
        </ul>
        <div class="widthauto pages_box">
            <a @click="pageNumGetList(1)">首页</a>
            <a @click="pageNextList(-1)">上一页</a>
<!--            <a v-for="item in pageInfo.total" @click="pageNumGetList(item)">{{item}}</a>-->
            <a v-for="(item,index) in pageInfo.total" :class="(index+1)==current_page?'pages_box_cur':''" @click="pageNumGetList(item)">{{item}}</a>
            <a @click="pageNextList(1)">下一页</a>
            <a  @click="pageNumGetList(pageInfo.total)">尾页</a>
        </div>
    </div>
    {include file="public/right"}
</div>
{include file="public/footer"}
<!--全国省份-->
<script src="/static/util/distpicker/distpicker.min.js"></script>
<script>
    var sourceListVm = new Vue({
        el:'#sourceList',
        data:{
            current_page:'1',//当前页
            num:'15',//每页显示几条
            serviceList:[],
            tradeList:[],
            trade_name:'',
            service_name:'',
            province:'',
            end_time_status:'',
            title_search:'',
            list:[],
            pageInfo:{},
            nowString:''
        },
        methods:{
            getTradeChildList:function(){
                var el = this
                AjaxPost({"trade_id":2},'/index/trade/getTradeChildByWhere').then((response)=>{
                    el.serviceList = response.result
                })
                AjaxPost({"trade_id":1},'/index/trade/getTradeChildByWhere').then((response)=>{
                    el.tradeList = response.result
                })
            },
            pageNumGetList:function(page){
                var el = this
                el.current_page = page
                el.getList()
            },
            pageNextList:function (num) {
                var el = this;
                var set_current_page = el.current_page*1+num
                // el.current_page = el.pageInfo.current_page*1+num
                console.log(el.current_page)
                if( set_current_page < 1){
                    $.customToastr("error","已经是第一页啦");
                    return;
                }
                if(set_current_page > el.pageInfo.total){
                    $.customToastr("error","已经是最后一页啦");
                    return;
                }
                el.current_page = set_current_page
                el.getList();
            },
            //条件更改无法从第一页查询，跳转方法
            changeWhereGetList:function(){
                var el = this
                el.current_page = 1
                el.getList()
            },
            getList:function () {
                let el = this
                var paging = {
                    "current_page":el.current_page,
                    'num':el.num
                }
                var whereTime = ''
                var title = ''
                if(el.end_time_status == 1){
                    whereTime = 1
                }
                if(el.end_time_status == 2){
                    whereTime = 2
                }
                if(el.title_search != ''){
                    title = el.title_search
                }
                var where = {"item_category":2}
                if(el.trade_name !=''){
                    where['trade_name'] = el.trade_name
                }
                if(el.service_name != ''){
                    where['service_name'] = el.service_name
                }
                if(el.province != ''){
                    where['province'] = el.province
                }
                var postDate = {
                    "where":where,
                    "paging":paging,
                    "whereTime":whereTime,
                    "title":title
                }
                AjaxPost(postDate,'/index/source/getSourceListPage').then((response)=>{
                    if(response.status == 1){
                        var list = response.result.list
                        if(list){
                            var arrayItem = [];
                            $.each(list,function (j,k) {
                                if(el.getTime(k.end_time)>el.getTime()){
                                    k['end_time_status'] = 1
                                }else{
                                    k['end_time_status'] = 2
                                }
                            })
                            el.list = list
                            el.pageInfo = response.result.pageInfo
                        }else {
                            el.list = []
                            el.pageInfo={}
                        }


                    }

                })
            },
            getTime:function (dateString='') {
                var time = ''
                if(dateString==''){
                    time =  new Date()
                }else {
                    time =  new Date(dateString)
                }
                return time.getTime()
            }
        },
        mounted(){
            this.$nextTick(function () {
                this.getTradeChildList()
                this.getList()
                this.getTime()
            })
            $('#distpicker').distpicker();
        }
    })
</script>